package com.boot.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.boot.dao.AdminDao;
import com.boot.entity.Admin;
import com.boot.exception.ServiceException;
import com.boot.service.AdminService;
import org.springframework.stereotype.Service;

/**
 * 管理员表(Admin)表服务实现类
 *
 * @author makejava
 * @since 2023-07-20 18:48:25
 */
@Service("adminService")
public class AdminServiceImpl extends ServiceImpl<AdminDao, Admin> implements AdminService {

    @Override
    public Admin selectByName(String name, String password) {

        try {
            Admin admin = this.query().eq("name", name).one();
            if(admin.getPassword().equals(password)){
                return admin;
            }else throw new ServiceException(402,"密码错误");
        }catch (Exception e){
            throw new ServiceException(401,"用户名不存在");
        }
    }
}

